import { NavigationActions } from 'react-navigation';
import { NAVIGATIONS, GLOBAL } from '../../../../config/global';

class OrderCreactService {

  CURRENCY_ENUM = [{
    dictKey: 'RMB',
    dictName: '人民币',
  }, {
    dictKey: 'USD',
    dictName: '美元',
  }]

  jump (page, params, cb) {
    this.props.navigation.navigate(page, {
      ...params,
      callBack: cb,
    });
  }

  reset (orderType, tCode, status) {
    let actions = [NavigationActions.navigate({ routeName: 'HomePage' })];
    // tabIndex 0，1，2（销售成交，采购成交，闭口销售)
    // tabIndex 0，1（销售成交，采购成交)--长约
    // status 订单状态
    let params = { statusIndex: status };
    if (tCode === 'C') {
      params.typeIndex = 0;
    } else {
      params.typeIndex = orderType === 'S' ? 0 : 1;
    }
    let targetR = NavigationActions.navigate({ routeName: 'OrderListPage', params })
    actions.push(targetR);
    if (GLOBAL.TAB_NAVIGATION.name !== 'HOME') GLOBAL.TAB_NAVIGATION.popToTop()
    NAVIGATIONS['HOME'].reset(actions, 1);
  }

  isNeedPaymentDays = (name) => {
    let index = name.indexOf('@@');
    return index > -1
  }

}

module.exports = new OrderCreactService();